package com.oscar.helper;

import android.content.Context;
import android.content.SharedPreferences;

public class SettingsHelper {
	private static final String SPF_NAME = "settings";
    private static final String NOTIFICATION = "NOTIFICATION"; 
    private static final String NOTIFICATION_VIBRATE = "NOTIFICATION_VIBRATE";
    private static final String USERNAME_STORED = "USERNAME_STORED";
	public SettingsHelper()
	{
	}
	public static Boolean setSettingsNotification(Context context, Boolean notification)
	{
		try
		{
			SharedPreferences receiverPreferences = context.getSharedPreferences(SPF_NAME, Context.MODE_PRIVATE);
			receiverPreferences.edit().putBoolean(NOTIFICATION, notification).commit();
			return true;
		}catch(Exception e)
		{
			return false;
		}
	}
	public static Boolean setSettingsNotificationVibrate(Context context, Boolean notificationVibrate)
	{
		try
		{
			SharedPreferences receiverPreferences = context.getSharedPreferences(SPF_NAME, Context.MODE_PRIVATE);
			receiverPreferences.edit().putBoolean(NOTIFICATION_VIBRATE, notificationVibrate).commit();
			return true;
		}catch(Exception e)
		{
			return false;
		}
	}
	
	public static Boolean getSettingsNotification(Context context)
	{
		SharedPreferences loginPreferences = context.getSharedPreferences(SPF_NAME,
                Context.MODE_PRIVATE);
		return loginPreferences.getBoolean(NOTIFICATION, true);
	}
	public static Boolean getSettingsNotificationVibrate(Context context)
	{
		SharedPreferences loginPreferences = context.getSharedPreferences(SPF_NAME,
                Context.MODE_PRIVATE);
		return loginPreferences.getBoolean(NOTIFICATION_VIBRATE, true);
	}
	public static void setUserNameStored(Context context, String username)
	{
			SharedPreferences receiverPreferences = context.getSharedPreferences(SPF_NAME, Context.MODE_PRIVATE);
			receiverPreferences.edit().putString(USERNAME_STORED, username).commit();
	}
	public static String getUserNameStored(Context context)
	{
		SharedPreferences loginPreferences = context.getSharedPreferences(SPF_NAME,
                Context.MODE_PRIVATE);
		return loginPreferences.getString(USERNAME_STORED, "");
	}
	
	
}
